package ronglei.day01.demo06ArrayList;

import java.util.ArrayList;
//生成四个学生累
public class ArrayLietPerson06 {
    public static void main(String[] args) {
        Person one = new Person("荣磊",13);
        Person two = new Person("王冰心",18);
        Person three = new Person("荣心",3);

        Person[] array = new Person[3];
        array[0] = one;
        array[1] = two;
        array[2] = three;
        System.out.println(array[0].toString());
        for (int i = 0; i < array.length; i++) {
            System.out.println(array[1]);
        }


        ArrayList<Person> objects = new ArrayList<>();
        objects.add(one);
        objects.add(two);
        objects.add(three);
        System.out.println(objects.toString());


        objects.clear();//移除所有元素
        System.out.println(objects);
        for (int i = 0; i < objects.size(); i++) {
            Person stu =objects.get(i);
            System.out.println("姓名：" + stu.getName() + "年龄："+ stu.getAge());
        }
        

    }
}
